package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BusSupplieeInfo;
import com.ruoyi.system.service.IBusSupplieeInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 供应商信息Controller
 * 
 * @author hst
 * @date 2021-12-15
 */
@RestController
@RequestMapping("/system/suppliee")
public class BusSupplieeInfoController extends BaseController
{
    @Autowired
    private IBusSupplieeInfoService busSupplieeInfoService;

    /**
     * 查询供应商信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:suppliee:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusSupplieeInfo busSupplieeInfo)
    {
        startPage();
        List<BusSupplieeInfo> list = busSupplieeInfoService.selectBusSupplieeInfoList(busSupplieeInfo);
        return getDataTable(list);
    }

    /**
     * 导出供应商信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:suppliee:export')")
    @Log(title = "供应商信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusSupplieeInfo busSupplieeInfo)
    {
        List<BusSupplieeInfo> list = busSupplieeInfoService.selectBusSupplieeInfoList(busSupplieeInfo);
        ExcelUtil<BusSupplieeInfo> util = new ExcelUtil<BusSupplieeInfo>(BusSupplieeInfo.class);
        return util.exportExcel(list, "供应商信息数据");
    }

    /**
     * 获取供应商信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:suppliee:query')")
    @GetMapping(value = "/{supplierId}")
    public AjaxResult getInfo(@PathVariable("supplierId") Long supplierId)
    {
        return AjaxResult.success(busSupplieeInfoService.selectBusSupplieeInfoBySupplierId(supplierId));
    }

    /**
     * 新增供应商信息
     */
    @PreAuthorize("@ss.hasPermi('system:suppliee:add')")
    @Log(title = "供应商信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusSupplieeInfo busSupplieeInfo)
    {
        return toAjax(busSupplieeInfoService.insertBusSupplieeInfo(busSupplieeInfo));
    }

    /**
     * 修改供应商信息
     */
    @PreAuthorize("@ss.hasPermi('system:suppliee:edit')")
    @Log(title = "供应商信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusSupplieeInfo busSupplieeInfo)
    {
        return toAjax(busSupplieeInfoService.updateBusSupplieeInfo(busSupplieeInfo));
    }

    /**
     * 删除供应商信息
     */
    @PreAuthorize("@ss.hasPermi('system:suppliee:remove')")
    @Log(title = "供应商信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{supplierIds}")
    public AjaxResult remove(@PathVariable Long[] supplierIds)
    {
        return toAjax(busSupplieeInfoService.deleteBusSupplieeInfoBySupplierIds(supplierIds));
    }
}
